package com.cee.service.Impl;

import com.cee.dao.CompletionMapper;
import com.cee.dto.CompletionDTO;
import com.cee.model.Completion;
import com.cee.service.CompletionService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Slf4j
@Service
@Transactional
public class CompletionServiceImpl implements CompletionService {

    @Autowired
    private CompletionMapper completionMapper;

    @Override
    public int saveCompletion(Completion completion) throws Exception {
       return completionMapper.insert(completion);
    }

    @Override
    public List<CompletionDTO> getCompletionList(CompletionDTO completionDTO) {
        return completionMapper.getCompletionList(completionDTO);
    }

    @Override
    public List<CompletionDTO> getListByExamId(Integer examId) {
        return completionMapper.getListByExamId( examId);
    }

    @Override
    public void deleteCompletion(Integer id) {
        Completion completion = new Completion();
        completion.setId(id);
        completion.setDelDateTime(new Date());

        log.info("逻辑删除completion, id={}", id);
        completionMapper.updateCompletionById(completion);
    }
}
